perm filename SYNTAX.DOC[206,JMC] blob
sn#005352 filedate 1971-11-24 generic text, type T, neo UTF8
␈⊃
␈⊃
␈⊃
␈⊃ SYNTAX DIRECTED COMPUTATION
␈⊃
␈⊃ It is often more convenient to describe certain kinds of
␈⊃computation with symbolic expressions by "syntax transformations"
␈⊃than by recursive LISP functions. For example, consider the
␈⊃simplification of expressions in a binary PLUS and TIMES where
␈⊃the number 0 is to be eliminated from sums, the number 1 is to be
␈⊃eliminated from products, products containing 0 are to be replaced
␈⊃by 0, and sums and products of one element are to be replaced by
␈⊃that element. This may be accomplished by the function simplifya
␈⊃defined by
␈⊃ simplifya e ← __ __ e ____ e
if at then
␈⊃ ____ {simplifya __ e,simplifya ___ e}
else ad add
␈⊃ [λwz. __ _ e __ PLUS ____
if a eq then
␈⊃ [__ w = 0 ____ z
if then
␈⊃ ____ __ z = 0 ____ w
else if then
␈⊃ ____ _____ _ ___
else <PLUS w z>]
␈⊃ ____ __ w = 0 ∨ z = 0 ____ 0
else if then
␈⊃ ____ __ w = 1 ____ z
else if then
␈⊃ ____ __ z = 1 ____ w
else if then
␈⊃ ____ <TIMES w z>.
else
␈⊃